using System;
using UnityEngine;

public class BasicElement : MonoBehaviour
{
	
	public void Start()
	{
		gameObject.AddComponent<Rigidbody>();
		rigidbody.mass = 10.0f;
		rigidbody.isKinematic = true;
		
		SphereCollider sphereCollider = gameObject.AddComponent<SphereCollider>();
		sphereCollider.radius = 0.7f;
	}
	
	public void OnCollisionEnter(Collision collision)
	{
		if (collision.gameObject.tag != "Player")
			return;
		
		Rigidbody playerBody = collision.gameObject.GetComponent<Rigidbody>();
		Vector3 reflected = Vector3.Reflect(collision.gameObject.transform.position, Vector3.up);
		
		playerBody.AddForce(new Vector3(reflected.x, reflected.y, reflected.z), ForceMode.Impulse);
	}
}

